package cn.bdqn.controller;

import cn.bdqn.entity.Film;
import cn.bdqn.service.FilmService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import javax.annotation.Resource;

@RestController
@RequestMapping("film")
public class FilmController {
    @Resource
    private FilmService filmService;
    
    @GetMapping
    public ResponseEntity<List<Film>> queryAll() {
        return ResponseEntity.ok(this.filmService.queryAll());
    }

    @GetMapping("{id}")
    public ResponseEntity<Film> queryById(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(this.filmService.queryById(id));
    }

    @PostMapping
    public ResponseEntity<Film> add(Film film) {
        return ResponseEntity.ok(this.filmService.insert(film));
    }

    @PutMapping
    public ResponseEntity<Film> edit(Film film) {
        return ResponseEntity.ok(this.filmService.update(film));
    }
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(Integer id) {
        return ResponseEntity.ok(this.filmService.deleteById(id));
    }

}

